package com.wgq.TestPaiXu;

import java.util.Comparator;
import java.util.Date;

//实现Comparator(排序)重写compare
public class teiZi  implements Comparator,Comparable{
    private String name;
    private  int dianJiLiang;
    private Date crateTime;
    public teiZi(String name, int dianJiLiang, Date crateTime) {
        this.name = name;
        this.dianJiLiang = dianJiLiang;
        this.crateTime = crateTime;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getDianJiLiang() {
        return dianJiLiang;
    }

    public void setDianJiLiang(int dianJiLiang) {
        this.dianJiLiang = dianJiLiang;
    }

    public Date getCrateTime() {
        return crateTime;
    }

    public void setCrateTime(Date crateTime) {
        this.crateTime = crateTime;
    }


    @Override
    public int compare(Object o1, Object o2) {
        return 0;
    }

    @Override
    public int compareTo(Object o) {
        teiZi t =(teiZi)o;
        int c=0;
        c = this.crateTime.compareTo(t.crateTime);
        if(0==c){
            c = this.dianJiLiang-t.dianJiLiang;
            if(0==c){
                c=this.name.compareTo(t.name);
            }
        }
        return c;
    }
}
